<script type="text/javascript">
<!--
$(function(){
	//$("button[name=links_button]").button();
});


function showLogoInput(object){
	object.change(function(){
		if($(this).val() == <?php echo Links::LINK_IMAGE;?>){
			$("#Links_link_logo").parent().fadeIn();
		}else{
			$("#Links_link_logo").parent().hide();
		}
	});
}
//-->
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'links-form',
	'enableAjaxValidation'=>true,
)); ?>

	<?php echo Yii::t('admin','<p class="note">Fields with <span class="required">*</span> are required.</p>');?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'link_name'); ?>
		<?php echo $form->textField($model,'link_name',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'link_name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'link_href'); ?>
		<?php echo $form->textField($model,'link_href',array('size'=>60,'maxlength'=>500)); ?>
		<?php echo $form->error($model,'link_href'); ?>
	</div>


	<div class="row column3">
		<?php echo $form->labelEx($model,'link_type'); ?>
		<?php echo $form->dropDownList($model,'link_type',Links::model()->generateLinkTypeDropDownList(),array(
				'onclick'=>'showLogoInput($(this))'
		)); ?>
		<?php echo $form->error($model,'link_type'); ?>
	</div>
	
	<div class="row column3">
		<?php echo $form->labelEx($model,'link_order'); ?>
		<?php echo $form->textField($model,'link_order'); ?>
		<?php echo $form->error($model,'link_order'); ?>
	</div>
	
	<div class="row column3">
		<?php echo $form->labelEx($model,'link_status'); ?>
		<?php echo $form->dropDownList($model,'link_status',Links::model()->generateLinkStatusDropDownList()); ?>
		<?php echo $form->error($model,'link_status'); ?>
	</div>
		
	<div class="clear"></div>
	
	<div class="row hide">
		<?php echo $form->labelEx($model,'link_logo'); ?>
		<?php echo $form->textField($model,'link_logo',array('size'=>60,'maxlength'=>500)); ?>
		<?php echo $form->error($model,'link_logo'); ?>
	</div>



	<div class="row">
		<?php echo $form->labelEx($model,'link_description'); ?>
		<?php echo $form->textArea($model,'link_description',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'link_description'); ?>
	</div>

	<div class="row buttons">
		<hr class="space" />
		<?php 
		
		$update = $this->createUrl('links/update',array('id'=>$model->link_id));
		$create = $this->createUrl('links/createajax');
		
		$this->widget('zii.widgets.jui.CJuiButton',
				array(
					'name'=>'button',
					'buttonType'=>'button',
					'caption'=>$model->isNewRecord ? Yii::t('admin', 'Create') : Yii::t('admin', 'Save'),
//					'onclick'=>'js:function(){alert("Save button clicked"); this.blur(); return false;}',
//					'onclick'=>$model->isNewRecord ? 'js:function(){actionCreate($(this))}' : 'js:function(){actionUpdate($(this))}',
					'htmlOptions'=>array(
						'onclick'=>$model->isNewRecord?'actionCreate($(this));':'actionUpdate($(this));',
						'cid'=> $model->isNewRecord?$create:$update
//						'id'=>$model->isNewRecord?$this->createUrl('links/update',array('id'=>$model->link_id)):$this->createUrl('links/create')
					),
				)
			);
		?>	
		<!-- <button name="links_button"  type="button" onclick="<?php echo $model->isNewRecord?'actionCreate($(this));':'actionUpdate($(this));';?>" id="<?php echo $model->isNewRecord?$this->createUrl('links/createajax'):$this->createUrl('links/update',array('id'=>$model->link_id));?>"><?php echo $model->isNewRecord ? Yii::t('admin', 'Create') : Yii::t('admin', 'Save');?></button>
	 -->
	 </div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<?php $this->widget('ext.box.colorbox.colorboxWidget',array(
		'id'=>'#example',
		'theme'=>'example1',
//		'options'=>'width:"50%", inline:true, href:"#uploadbox",onClosed:function(){ load(); }'
));?> 
<?php $this->widget('ext.msgbox.msgboxWidget');?>